home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
cheetah.zip
/
VGADRV.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-09
|
13KB
|
340 lines
/* VGADRV.H (VGA-level) SCREEN library
* Description:
* VGA mode 13h defines and macros.
* Portability: BORLANDC
* $Header: egadrv.h,v 1.2 91/06/02 16:09:07 erdy Exp $
* Copyright (c) erdy 1992
*/
#ifndef _VGADRV_H_
# define _VGADRV_H_
/*
* Keys to grswitch:
*/
#define GRSWITCH_EXIT 0
#define GRSWITCH_SOFF 0x10 /* Disable refreshing */
#define GRSWITCH_CMODE 0x20 /* Switch to chained mode */
#define GRSWITCH_UMODE 0x40 /* Switch to unchained mode */
#define SCMODE_CHAINED 0
#define SCMODE_UNCHAINED 1
extern struct Svideo {
char aname[8]; /* ê¼∩ áñá»ΓÑαá */
unsigned int page_seg[4];
unsigned int vpage; /* é¿ñ¿¼á∩ ßΓαá¡¿µá */
unsigned int opage; /* æΓαá¡¿µá ñ½∩ óδó«ñá */
union saddress {
unsigned int w;
char b[2];
} saddress[2];
union saddress top;
int oldmode; /* ÉѪ¿¼ αáí«Γδ áñá»ΓÑαá */
} Sadapter;
/* MCGA CHAINED/UNCHAINED mode settings:
* -------------------------------------
*/
#if defined(VGA_DUALMODE) && !defined(VGA_UNCHAINED)
# define VGA_UNCHAINED
#endif
/* MCGA Common settings: */
#define VGA_RAM ((char far *)0xA0000000) /* VGA Video RAM address */
#define VGA_RAMSIZE 0x10000 /* Size of RAM, as mapped to host */
#define VGA_SEG0 0xA000 /* Segment address of VRAM */
#define PPERBYTE 1 /* Pixels per byte */
#define BITPLANES 4
#define MAXROWS 200
#define MAXCOLS 320
#define MAXCOLORS 256
#define MAXCOLORCODE 63
#define BPERDCOLOR 3 /* Byte per direct color code */
#define PALETTESIZE (MAXCOLORS*BPERDCOLOR)
#define ASP_RATIO 0.7
#define ASP_RATIO_NUMERATOR 7
#define ASP_RATIO_DENOMINATOR 10
/* MCGA ChainFourOn (standard) mode settings: */
#define MAXPAGES_CHAINED 1
#define VGA_SEG1_CHAINED 0xAFA0
#define VGA_PSIZE_CHAINED 0xFA00 /* = 64000. Graphic Page length */
#define BPERROW_CHAINED 320 /* Bytes per scanline */
#define BPERSCREEN_CHAINED 320
/* MCGA ChainFourOff mode settings: */
#define MAXPAGES_UNCHAINED 4
#define VGA_SEG1_UNCHAINED 0xA3E8
#define VGA_SEG2_UNCHAINED 0xA7D0
#define VGA_SEG3_UNCHAINED 0xABB8
#define VGA_PSIZE_UNCHAINED 0x3E80 /* =16000. Graphic Page length */
#define BPERROW_UNCHAINED 80 /* Bytes per scanline */
#define BPERSCREEN_UNCHAINED 80
#ifdef VGA_UNCHAINED
# ifndef BPERROW
# define BPERROW BPERROW_UNCHAINED
# else BPERROW
# define VGA_BPERROW
# endif BPERROW
# define BPERSCREEN BPERSCREEN_UNCHAINED
# define MAXPAGES MAXPAGES_UNCHAINED
# define VGA_SEG1 VGA_SEG1_UNCHAINED
# define VGA_SEG2 VGA_SEG2_UNCHAINED
# define VGA_SEG3 VGA_SEG3_UNCHAINED
# define VGA_PSIZE VGA_PSIZE_UNCHAINED
#else VGA_UNCHAINED
# ifndef BPERROW
# undef BPERROW
# define BPERROW BPERROW_CHAINED
# endif BPERROW
# define BPERSCREEN BPERSCREEN_CHAINED
# define MAXPAGES MAXPAGES_CHAINED
# define VGA_SEG1 VGA_SEG1_CHAINED
# define VGA_SEG2 VGA_SEG1_CHAINED
# define VGA_SEG3 VGA_SEG1_CHAINED
# define VGA_PSIZE VGA_PSIZE_CHAINED
#endif VGA_UNCHAINED
#define VIDEO_UYTOADDRESS(y) (y*BPERROW)
#define VIDEO_CYTOADDRESS(y) (y*BPERROW_CHAINED)
#define VIDEO_UXTOADDRESS(x) (x>>2)
#define VIDEO_CXTOADDRESS(x) x
#define VIDEO_UADDRESS(x, y) (VIDEO_UXTOADDRESS(x)+VIDEO_UYTOADDRESS(y))
#define VIDEO_CADDRESS(x, y) (VIDEO_CXTOADDRESS(x)+VIDEO_CYTOADDRESS(y))
#ifdef VGA_DUALMODE
# define VIDEO_ADDRESS(x, y) \
(Scmode == SCMODE_CHAINED)? VIDEO_CADDRESS(x, y):VIDEO_UADDRESS(x,y)
#elif defined(VGA_UNCHAINED)
# define VIDEO_ADDRESS(x, y) VIDEO_UADDRESS(x, y)
#else VGA_UNCHAINED
# define VIDEO_ADDRESS(x, y) VIDEO_CADDRESS(x, y)
#endif
#define _DefaultRMode READMODE0
#define _DefaultWMode WRITEMODE0
#define _setDefaultRWModes()
/*
* Hardware macros:
* ----------------
*/
#define VGA_CRTC_ADR 0x3D4 /* CRT Controller, Address Register */
#define VGA_CRTC_GATE 0x3D5 /* CRT Controller, Index/Data Register */
# define _CRT_OVERFLOW 7
# define _CRT_MAXSCANLINE 9
# define _CRT_CURSOR_START 10
# define _CRT_CURSOR_STOP 11
# define _CRT_STARTAD_HIGH 12
# define _CRT_STARTAD_LOW 13
# define _CRT_CURPOS_HIGH 14
# define _CRT_CURPOS_LOW 15
# define _CRT_LINECOMPARE 0x18
# define _CURSOR_OFF 0360
#define VGA_ATC 0x3C0 /* Attribute Controller Registers, Addr. reg. */
#define VGA_GADR 0x3CE /* Graphic Controller Registers, Addr. reg. */
#define VGA_GCD 0x3CF /* Graphic Controller Registers, Data reg. */
# define _GCD_SETRES 0 /* óδí«α αÑú¿ßΓαá ßíα«ßá/πßΓá¡«ó¬¿ GCD */
# define _GCD_ENSET 1 /* óδí«α αÑú¿ßΓαá αáºαÑΦÑ¡¿∩ ßíα/πßΓ. GCD*/
# define _GCD_CCOMPARE 2 /* óδí«α αÑú¿ßΓαá ßαáó¡Ñ¡¿∩ µóÑΓ«ó GCD*/
# define _GCD_ROTATE 3 /* óδí«α αÑú¿ßΓαá óαáΘÑ¡¿∩ GCD */
# define _GCD_MAPSEL 4 /* óδí«α óδí«αá ¬áαΓδ */
# define _GCD_MODES 5 /* óδí«α αÑú¿ßΓαá αѪ¿¼«ó GCD */
# define _GCD_DONTCARE 7 /* óδí«α αÑú¿ßΓαá íѺαẽ¿τ¿∩ µóÑΓá */
# define _GCD_BITMASK 8 /* óδí«α αÑú¿ßΓαá í¿Γ«ó«⌐ ¼á߬¿ GCD */
/* ÉѪ¿¼δ ºá»¿ß¿ ¿ τΓÑ¡¿∩: */
# define WRITEMODE0 0
# define WRITEMODE1 1
# define WRITEMODE2 2
# define WRITEMODE3 3
# define WRITEMODEMASK 3
# define READMODE0 0
# define READMODE1 010
# define READMODEMASK 010
#define AND_LOGIC 010
#define XOR_LOGIC 030
#define OR_LOGIC 020
#define VGA_SER_ADR 0x3C4 /* Sequencer Registers, Addr. reg. */
#define VGA_SER_GATE 0x3C5 /* Sequencer Registers, Data. reg. */
# define _SER_CM_RESET 0
# define _SER_CM_REG 1 /* Clocking Mode register */
# define _SER_MAPMASK 2 /* Map Mask register */
# define _SER_MM_REG 4 /* Memory Mode register */
#define _SER_CM_SO 0x20 /* 0 - Screen on, 1 - off */
#define _SER_CM_S4 0x10 /* Shift Four */
#define _SER_CM_DC 0x8 /* Dot clock */
#define _SER_CM_SL 0x4 /* Shift Load */
#define _SER_CM_BW 0x2 /* BW */
#define _SER_CM_89 0x1 /* 8/9 */
#define _SER_MM_C4 0x8 /* 1-Planes Chained, 0-Planes are to be selected */
#define VGA_PEL_WA 0x3c8 /* PEL address Write Mode register */
#define VGA_PEL_RA 0x3c7 /* PEL address Read Mode register */
#define VGA_PEL_DATA 0x3c9 /* PEL address Data register */
#define VGA_PEL_STA 0x3c7 /* DAC state */
#define VGA_PEL_MASK 0x3c6 /* PEL Mask register */
#define VGA_IS1 0x3DA /* Read: Input status # 1 */
#define VGA_STA 0x3DA /* Write: Feature Control 0 ¿½¿ 1 */
#define VGA_RETRACE 1 /* êñÑΓ ú«α¿º«¡Γá½∞¡δ⌐ ¿½¿ óÑαΓ¿¬á½∞¡δ⌐ retrace */
#define VGA_HRETRACE 1 /* êñÑΓ ú«α¿º«¡Γá½∞¡δ⌐ retrace */
#define VGA_VRETRACE 8 /* êñÑΓ óÑαΓ¿¬á½∞¡δ⌐ retrace */
#ifdef __TURBOC__
#define _chain4Off() asm {\
mov dx, VGA_SER_ADR;\
mov ax, 0x0604;\
out dx, ax;\
mov dx, VGA_CRTC_ADR;\
mov ax, 0x0014;\
out dx, ax;\
mov ax, 0xE317;\
out dx, ax;}
#define _chain4On() asm {\
mov dx, VGA_SER_ADR;\
mov ax, 0x0E04; /* SER/MM/[C4] 0xE on */\
out dx, ax;\
mov dx, VGA_CRTC_ADR;\
mov ax, 0x4014; /* CRTC/UL/[DW] 0x40 on */\
out dx, ax;\
mov ax, 0xA317; /* CRTC/MC/[W/B] off */\
out dx, ax;}
#define _screenOff() \
{asm mov dx, VGA_SER_ADR;asm mov al,_SER_CM_REG;asm out dx, al;\
asm inc dx;asm in al, dx;\
asm or al,_SER_CM_SO;asm out dx, al;}
#define _screenOn() \
{asm mov dx, VGA_SER_ADR;asm mov al,_SER_CM_REG;asm out dx, al;\
asm